<template>
  <div>
    <h1>商品详情</h1>
    <el-form ref="form" label-width="80px" style="width: 500px">
      <el-form-item label="商品名称">
        <el-input v-model="good.name"></el-input>
      </el-form-item>
      <el-form-item label="商品描述">
        <el-input v-model="good.subtitle"></el-input>
      </el-form-item>
      <el-form-item label="当前状态">
        <el-input v-if="good.status == 1" value="在售"></el-input>
        <el-input v-if="good.status == 2" value="已下架"></el-input>
      </el-form-item>
      <el-form-item label="所属分类">
        <el-input></el-input>
      </el-form-item>
      <el-form-item label="商品价格">
        <el-input v-model="good.price"
          ><template slot="append">元</template></el-input
        >
      </el-form-item>
      <el-form-item label="商品库存">
        <el-input v-model="good.stock"
          ><template slot="append">件</template></el-input
        >
      </el-form-item>
      <el-form-item label="商品图片">
        <el-image style="width:100px" :src="good.imageHost + good.mainImage"></el-image>
      </el-form-item>
      <el-form-item label="商品详情">
        <p v-html="good.detail">{{ good.detail }}</p>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { details } from "../../../http/http";

export default {
  name: "",
  components: {},
  props: [],
  data() {
    return {
      id: 1,
      good: {
        imageHost: "",
        mainImage: "",
      },
    };
  },
  computed: {},
  watch: {},
  created() {
    this.id = this.$route.params.id;
  },
  mounted() {
    this.details();
  },
  methods: {
    //   商品详情
    async details() {
      const { data: res } = await details(this.id);
      console.log(res);
      this.good = res.data;
    },
  },
};
</script>

<style lang='scss' scoped>
</style>
